﻿using Map;
using Microsoft.Xna.Framework;

namespace Map_Creator.MapInfo
{
    public class AutoTileGrid : TileStructGrid
    {
        private new AutoTileData[,] tiles;

        public override TileStruct this[int x, int y]
        {
            get
            {
                var tileData = tiles[x, y];
                if (tileData == null)
                    return null;
                if (tileData.Type == AutoTileType.AutoTile4)
                    return new AutoTile4(tileData);
                if (tileData.Type == AutoTileType.AutoTile5)
                    return new AutoTile5(tileData);
                return null;
            }
            set
            {
                if (value.Type == TileType.Auto4)
                    tiles[x, y] = (value as AutoTile4).AutoData;
                else if (value.Type == TileType.AutoDP)
                    tiles[x, y] = (value as AutoTile5).AutoData;
            }
        }

        public AutoTileGrid(int x,int y)
        {
            Size = new Point(x,y);
            tiles = new AutoTileData[x,y];
        }
    }
}
